package top.jandmla.excel.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.jandmla.excel.pojo.QueryPageDTO;
import top.jandmla.excel.bean.Name;
import top.jandmla.excel.service.NameService;
import top.jandmla.excel.service.serviceImpl.NameServiceImpl;
import top.jandmla.excel.util.result.BaseResult;

@RestController
public class NameController {

    @Autowired
    private NameService nameService;

    /**
     * 实现按照表明进行模糊查询实现搜索
     *
     * @param dto 查询条件
     * @return 查询结果
     */
    @PostMapping("selectPageAndName")
    public BaseResult<IPage<Name>> selectPageAndName(@RequestBody QueryPageDTO<Name> dto) {
        IPage<Name> page = nameService.selectPageAndName(dto);
        return page.getRecords().size() > 0 ? BaseResult.success(page) : BaseResult.fail(1, "查询数据失败！");
    }

}
